
import { _decorator, Component, Node,Label } from 'cc';
const { ccclass, property } = _decorator;

/**
 * Predefined variables
 * Name = gameStart
 * DateTime = Thu Apr 14 2022 22:15:50 GMT+0800 (中国标准时间)
 * Author = xiaopang125
 * FileBasename = gameStart.ts
 * FileBasenameNoExtension = gameStart
 * URL = db://assets/gameStart.ts
 * ManualUrl = https://docs.cocos.com/creator/3.4/manual/zh/
 *
 */
 
@ccclass('gameStart')
export class gameStart extends Component {
    // [1]
    score = 0;

    // [2]
    // @property
    // serializableDummy = 0;
    @property({type: Node})
    public yuan: Node | null = null;

    @property({type: Node})
    public dian: Node | null = null;

    @property({type: Label})
    public scoreLabel: Label | null = null;

    start () {
        this.node.on(Node.EventType.TOUCH_START, this.TouchStart, this)
        // [3]
    }

    private TouchStart() {
        // console.log(this.yuan);
        const piNum1=this.yuan.getComponent("Yuan").piNum1;
        const piNum2=this.yuan.getComponent("Yuan").piNum2;
        const hd=this.dian.getComponent("Dian").hd;
        
        if(piNum2<2&&hd>piNum1&&hd<piNum2){

            console.log("成功");
            this.yuan.getComponent("Yuan").drawArc();
            this.score++;
            this.scoreLabel.string=this.score+"";
            

            

        }else if(piNum2>2&&hd<(piNum2-2)){
            console.log("成功");
            this.yuan.getComponent("Yuan").drawArc();
            this.score++;
            this.scoreLabel.string=this.score+"";

        }else{
            console.log("失败");
        }

        console.log(hd,piNum1,piNum2);
       
        
    }

    // update (deltaTime: number) {
    //     // [4]
    // }
}

/**
 * [1] Class member could be defined like this.
 * [2] Use `property` decorator if your want the member to be serializable.
 * [3] Your initialization goes here.
 * [4] Your update function goes here.
 *
 * Learn more about scripting: https://docs.cocos.com/creator/3.4/manual/zh/scripting/
 * Learn more about CCClass: https://docs.cocos.com/creator/3.4/manual/zh/scripting/decorator.html
 * Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.4/manual/zh/scripting/life-cycle-callbacks.html
 */
